//
//  HomeGiftCell.m
//  GiftNote
//
//  Created by lanou on 15/8/12.
//  Copyright (c) 2015年 GN. All rights reserved.
//

#import "HomeGiftCell.h"
#import "HomeHeader.h"
#import "UIImageView+WebCache.h"

@implementation HomeGiftCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        _myImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, kHomeWidth - 20, 273 * (kHomeWidth - 20) / 600)];
        _myImageView.layer.masksToBounds = YES;
        _myImageView.layer.cornerRadius = 5;
        [self.contentView addSubview:_myImageView];
        
        
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(_myImageView.frame) - _myImageView.frame.size.height / 5, kHomeWidth - 40, _myImageView.frame.size.height / 6)];
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:_titleLabel];
        
        
        _view = [[UIView alloc]initWithFrame:CGRectMake(kHomeWidth * 5 / 6 - 20, 20, kHomeWidth / 6, 20)];
        _view.backgroundColor = [UIColor blackColor];
        _view.alpha = 0.5;
        _view.layer.masksToBounds = YES;
        _view.layer.cornerRadius = 10;
        [self.contentView addSubview:_view];
        
        
        _likeLabel = [[UILabel alloc] initWithFrame:CGRectMake(_view.frame.size.width / 3, _view.frame.size.height / 3, _view.frame.size.width * 2 / 3 - 5, _view.frame.size.height / 3)];
        _likeLabel.font = [UIFont systemFontOfSize:9];
        _likeLabel.textAlignment = NSTextAlignmentRight;
        _likeLabel.textColor = [UIColor whiteColor];
        [_view addSubview:_likeLabel];
        
        
        _likeImage = [[UIImageView alloc] initWithFrame:CGRectMake(_view.frame.size.width / 3 - 10, _view.frame.size.height / 3 - 2, 10, 10)];
        _likeImage.image = [UIImage imageNamed:@"iconfont-xihuan-1"];
        [_view addSubview:_likeImage];
        
    }
    return self;
}

- (void)setGiftModel:(HomeGiftModel *)giftModel{
    
    _giftModel = giftModel;
    
    [_myImageView sd_setImageWithURL:[NSURL URLWithString:_giftModel.cover_image_url] placeholderImage:[UIImage imageNamed:@"placeHolder"]];
    _titleLabel.text = _giftModel.title;
    _likeLabel.text = [NSString stringWithFormat:@"%ld",(long)[_giftModel.likes_count intValue]];
}

@end








